package routes

import (
	"dan/app/http/middleware"
	"dan/config"
	"dan/global"
	"dan/handler"
	"github.com/gin-gonic/gin"
)

func InitRouter() *gin.Engine {
	var r *gin.Engine
	if global.GinEngine == nil {
		r = gin.New()
	} else {
		r = global.GinEngine
	}
	if config.SslConfig.Enable {
		r.Use(handler.TlsHandler())
	}
	//中间件
	middleware.InitMiddleware(r)
	//路由
	InitWebRouter(r)

	return r
}
